package com.stone.serverless.dashboard.controller;//package com.stone.serverless.server;

import com.stone.serverless.dashboard.DashBoardConsumer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Description: TODO
 * @Author: MECHREVO
 * @Date: 2022/1/14 16:48
 * @Version: 1.0.0
 */
@RestController
public class ComponentController {

    @GetMapping("/all")
    public List<Map<String, String>> all() {
        List<Map<String, String>> res = DashBoardConsumer.INSTANCE.jarLoadService.componentInfo();
        return res;
    }

    @GetMapping("/api_list")
    public List<String> apiList(@RequestParam(value = "componentName") String componentName,
                                @RequestParam(value = "version") String version) {
        List<String> res = DashBoardConsumer.INSTANCE.jarLoadService.routerStatistics(componentName, version);
        return res;
    }

    @GetMapping("/services")
    public List<Map<String, String>> services(@RequestParam(value = "componentName") String componentName,
                                              @RequestParam(value = "version") String version) {
        return DashBoardConsumer.INSTANCE.jarLoadService.servicesStatistics(componentName, version);
    }
}
